package com.task.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.util.ObjectUtils;

/**
 * @Author 迪迦.
 * @Date 2023/5/18 17:41
 */
public enum DuplicateConditionEnum {
//  BY_NAME(0, "按名称", "byName", false, "MISSION_NAME"),
  BY_MISSION_ID(1, "按任务", "byMissionId", true, "MISSION_CODE"),
  BY_AFFILIATE_ID(2, "按联盟", "byAffiliateId", true, "AFFILIATE_CODE"),
  BY_ADVERTISER_ID(3, "按广告主", "byAdvertiserId", true, "ADVERTISER_CODE"),

  ;

  private Integer info;
  private String displayName;
  private String msg;
  private boolean codeList;
  private String column;


  DuplicateConditionEnum(Integer info, String displayName, String msg, boolean codeList, String column) {
    this.info = info;
    this.displayName = displayName;
    this.msg = msg;
    this.codeList = codeList;
    this.column = column;
  }

  public static DuplicateConditionEnum getEnumByInfo(int info) {
    if (!ObjectUtils.isEmpty(info)) {
      for (DuplicateConditionEnum value : DuplicateConditionEnum.values()) {
        if (info == value.getInfo()) {
          return value;
        }
      }
    }
    return DuplicateConditionEnum.BY_MISSION_ID;
  }

  public static DuplicateConditionEnum getEnumByName(String name) {
    if (!ObjectUtils.isEmpty(name)) {
      for (DuplicateConditionEnum value : DuplicateConditionEnum.values()) {
        if (name.equals(value.name())) {
          return value;
        }
      }
    }
    return DuplicateConditionEnum.BY_MISSION_ID;
  }

  /**
   * 获取列表.
   */
  public static List<Map<String, Object>> getList() {
    List<Map<String, Object>> list = new ArrayList<>();
    for (DuplicateConditionEnum value : DuplicateConditionEnum.values()) {
      Map<String, Object> map = new HashMap<>();
      map.put("value", value.name());
      map.put("label", value.getMsg());
      map.put("displayName", value.getDisplayName());
      map.put("codeList", value.isCodeList());
      list.add(map);
    }
    return list;
  }

  DuplicateConditionEnum() {
  }

  public Integer getInfo() {
    return info;
  }

  public String getDisplayName() {
    return displayName;
  }

  public String getMsg() {
    return msg;
  }

  public boolean isCodeList() {
    return codeList;
  }

  public String getColumn() {
    return column;
  }
}
